//
//  FDMHotRecommendsHeaderView.m
//  Entertainment
//
//  Created by dllo on 16/4/25.
//  Copyright © 2016年 付冬梅. All rights reserved.
//

#import "FDMHotRecommendsHeaderView.h"
#import "FDMHotRecommendsModel.h"

@interface FDMHotRecommendsHeaderView ()

@property (nonatomic, retain) UIImageView *titleView;

@end
@implementation FDMHotRecommendsHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.titleView = [[UIImageView alloc] init];
        [self addSubview:self.titleView];
        [self.titleView release];
        self.titleLabel = [[UILabel alloc] init];
        [self addSubview:self.titleLabel];
        [self.titleLabel release];
    }
    return self;
}

- (void)dealloc {
    [self.titleLabel release];
    [self.titleView release];
    [self.model release];
    [super dealloc];
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.titleView.image = [UIImage imageNamed:@"findsection_logo@2x.png"];
    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).with.offset(5);
        make.left.equalTo(self.mas_left).with.offset(10);
        make.bottom.equalTo(self.mas_bottom).with.offset(-5);
        make.width.mas_equalTo(@20);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).with.offset(10);
        make.left.equalTo(self.titleView.mas_left).with.offset(20);
        make.bottom.equalTo(self.mas_bottom).with.offset(-10);
        make.width.mas_equalTo(@(self.frame.size.width - 50));
    }];
}

- (void)setModel:(FDMHotRecommendsModel *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
        self.titleLabel.text = _model.title;
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
